public class test07 {
    class Solution {
        public int jump(int[] nums) {
            int cur = 0;
            int max = 0;
            int res = 0;
            if(nums.length<=1){
                return res;
            }
            for(int i = 0;i<nums.length;i++){
                max = Math.max(max,i+nums[i]);
                if(max>=nums.length-1){
                    res++;
                    return res;
                }
                if(i==cur){
                    res++;
                    cur = max;
                }
            }
            return res;
        }
    }
}
